home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / mimelib / bodypart.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-05-14  |  6.1 KB  |  157 lines

  1. //=============================================================================
  2. // File:       bodypart.h
  3. // Contents:   Declarations for DwBodyPart
  4. // Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
  5. // WWW:        http://www.fwb.gulf.net/~dwsauder/mimepp.html
  6. //
  7. // Copyright (c) 1996, 1997 Douglas W. Sauder
  8. // All rights reserved.
  9. //
  10. // IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
  11. // INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
  12. // THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
  13. // HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. //
  15. // DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
  16. // NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  17. // PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
  18. // BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
  19. // SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  20. //
  21. //=============================================================================
  22.  
  23. #ifndef DW_BODYPART_H
  24. #define DW_BODYPART_H
  25.  
  26. #ifndef DW_CONFIG_H
  27. #include <mimelib/config.h>
  28. #endif
  29.  
  30. #ifndef DW_STRING_H
  31. #include <mimelib/string.h>
  32. #endif
  33.  
  34. #ifndef DW_ENTITY_H
  35. #include <mimelib/entity.h>
  36. #endif
  37.  
  38. class DwMessage;
  39. class DwEntity;
  40. class DwBody;
  41.  
  42.  
  43. //=============================================================================
  44. //+ Name DwBodyPart -- Class representing a MIME body-part
  45. //+ Description
  46. //. {\tt DwBodyPart} represents a {\it body part}, as described in RFC-2045
  47. //. and RFC-2046.  A body part is an {\it entity}, so it has a collection
  48. //. of headers and a {\it body}.  A body part is different from a {\it message}
  49. //. in that a body part is part of a multipart body.
  50. //.
  51. //. In MIME++, a {\tt DwBodyPart} is a subclass of {\tt DwEntity}; therefore,
  52. //. it contains both a {\tt DwHeaders} object and a {\tt DwBody} object,
  53. //. and it is contained in a multipart {\tt DwBody} object.
  54. //.
  55. //. As with {\tt DwMessage}, most of the functionality of {\tt DwBodyPart} is
  56. //. implemented by the abstract class {\tt DwEntity}.
  57. //=============================================================================
  58. // Last modified 1997-08-23
  59. //+ Noentry ~DwBodyPart _PrintDebugInfo mNext sClassName
  60.  
  61.  
  62. class DW_EXPORT DwBodyPart : public DwEntity {
  63.  
  64. public:
  65.  
  66.     DwBodyPart();
  67.     DwBodyPart(const DwBodyPart& aPart);
  68.     DwBodyPart(const DwEntity& aPart);
  69.     DwBodyPart(const DwString& aStr, DwMessageComponent* aParent=0);
  70.     //. The first constructor is the default constructor, which sets the
  71.     //. {\tt DwBodyPart} object's string representation to the empty string
  72.     //. and sets its parent to {\tt NULL}.
  73.     //.
  74.     //. The second constructor is the copy constructor, which performs
  75.     //. a deep copy of {\tt aPart}.
  76.     //. The parent of the new {\tt DwBodyPart} object is set to {\tt NULL}.
  77.     //.
  78.     //. The third constructor copies {\tt aStr} to the {\tt DwBodyPart}
  79.     //. object's string representation and sets {\tt aParent} as its parent.
  80.     //. The virtual member function {\tt Parse()} should be called immediately
  81.     //. after this constructor in order to parse the string representation.
  82.     //. Unless it is {\tt NULL}, {\tt aParent} should point to an object of
  83.     //. a class derived from {\tt DwBody}.
  84.  
  85.     virtual ~DwBodyPart();
  86.  
  87.     const DwBodyPart& operator = (const DwBodyPart& aPart);
  88.     //. This is the assignment operator, which performs a deep copy of
  89.     //. {\tt aPart}.  The parent node of the {\tt DwBodyPart} object
  90.     //. is not changed.
  91.  
  92.     virtual DwMessageComponent* Clone() const;
  93.     //. This virtual function, inherited from {\tt DwMessageComponent},
  94.     //. creates a new {\tt DwBodyPart} on the free store that has the same
  95.     //. value as this {\tt DwBodyPart} object.  The basic idea is that of
  96.     //. a virtual copy constructor.
  97.  
  98.     static DwBodyPart* NewBodyPart(const DwString& aStr,
  99.         DwMessageComponent* aParent);
  100.     //. Creates a new {\tt DwBodyPart} on the free store.
  101.     //. If the static data member {\tt sNewBodyPart} is {\tt NULL},
  102.     //. this member function will create a new {\tt DwBodyPart}
  103.     //. and return it.  Otherwise, {\tt NewBodyPart()} will call
  104.     //. the user-supplied function pointed to by {\tt sNewBodyPart},
  105.     //. which is assumed to return an object from a class derived from
  106.     //. {\tt DwBodyPart}, and return that object.
  107.  
  108.     DwBodyPart* Next() const;
  109.     //. This member function returns the next {\tt DwBodyPart} object
  110.     //. following this {\tt DwBodyPart} in the list of {\tt DwBodyPart}
  111.     //. objects contained in a multipart {\tt DwBody}.
  112.  
  113.     void SetNext(const DwBodyPart* aPart);
  114.     //. This advanced function sets {\tt aPart} as the next {\tt DwBodyPart}
  115.     //. object following this {\tt DwBodyPart} in the list of {\tt DwBodyPart}
  116.     //. objects contained in a multipart {\tt DwBody}.  Since {\tt DwBody}
  117.     //. contains a member function for adding a {\tt DwBodyPart} object to
  118.     //. its list, this function should be avoided for most applications.
  119.  
  120.     //+ Var sNewBodyPart
  121.     static DwBodyPart* (*sNewBodyPart)(const DwString&, DwMessageComponent*);
  122.     //. If {\tt sNewBodyPart} is not {\tt NULL}, it is assumed to point to a
  123.     //. user-supplied function that returns an object from a class
  124.     //. derived from {\tt DwBodyPart}.
  125.  
  126. public:
  127.  
  128.     virtual void PrintDebugInfo(std::ostream& aStrm, int aDepth=0) const;
  129.     //. This virtual function, inherited from {\tt DwMessageComponent},
  130.     //. prints debugging information about this object to {\tt aStrm}.
  131.     //. It will also call {\tt PrintDebugInfo()} for any of its child
  132.     //. components down to a level of {\tt aDepth}.
  133.     //.
  134.     //. This member function is available only in the debug version of
  135.     //. the library.
  136.  
  137.     virtual void CheckInvariants() const;
  138.     //. Aborts if one of the invariants of the object fails.  Use this
  139.     //. member function to track down bugs.
  140.     //.
  141.     //. This member function is available only in the debug version of
  142.     //. the library.
  143.  
  144. protected:
  145.  
  146.     void _PrintDebugInfo(std::ostream& aStrm) const;
  147.  
  148. private:
  149.  
  150.     const DwBodyPart* mNext;
  151.     static const char* const sClassName;
  152.  
  153. };
  154.  
  155. #endif
  156.  
  157.